
#!/bin/bash
#杀死之前的进程
input1=blog-web.jar
logDate=$(date "+%Y年-%m月-%d日%H:%M:%S")
PID=$(ps -ef | grep  $input1  | grep -v grep | awk '{print $2}')

if ps -p $PID > /dev/null
then
   echo "结束进程$PID"
  sudo  kill $PID

   # Do something knowing the pid exists, i.e. the process with $PID is running
fi
echo $PID
echo "清除原项目"
#创建日志
   touch /data/javaproject/logs/$logDate.txt
   rm -rf /data/javaproject/blog-web.jar
   cp /var/lib/jenkins/workspace/zyjblog/blog-web/target/blog-web.jar /data/javaproject/
 nohup java -jar /data/javaproject/blog-web.jar -> /data/javaproject/logs/$logDate.txt 2>&1 &